const mysql = require('mysql2/promise');

async function checkMerchantsStructure() {
  const connection = await mysql.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'root',
    database: 'community_service_platform'
  });

  try {
    console.log('🔍 检查商家表结构...\n');

    // 检查表结构
    const [columns] = await connection.execute('DESCRIBE merchants');
    console.log('📋 表结构:');
    columns.forEach(col => {
      console.log(`  ${col.Field} (${col.Type}) - ${col.Null === 'YES' ? '可空' : '非空'} - ${col.Key || '无键'}`);
    });

    // 检查数据
    const [merchants] = await connection.execute('SELECT * FROM merchants LIMIT 3');
    console.log('\n📊 数据示例:');
    merchants.forEach((merchant, index) => {
      console.log(`记录${index + 1}:`, JSON.stringify(merchant, null, 2));
    });

  } catch (error) {
    console.error('❌ 检查失败:', error.message);
  } finally {
    await connection.end();
  }
}

checkMerchantsStructure().catch(console.error);
